extends ../layouts/basic

block variablesLang
    include ./_variablesLang.jade

block extra_head
    <title>Coding Standard - Apache ECharts (incubating)</title>

    link(rel='stylesheet', type='text/css', href='#{cdnRoot}/#{ecWWWLang}/vendors/prettify/prettify.css')
    script(type='text/javascript', src='#{cdnRoot}/#{ecWWWLang}/vendors/prettify/prettify.js')
    script(type='text/javascript', src='#{cdnRoot}/#{ecWWWLang}/vendors/prettify/lang-css.js')


block content
    nav(class='navbar navbar-default navbar-fixed-top')
        include ./nav

    .page-info
        h1 Coding Standard
        p Please follow this standard when contribute to ECharts project.

    .page-content.single-page
        .page-nav
            ul#standard-nav
        .page-detail
            include ../../_generated/coding-standard-content.html

block extra_js

    script(type='text/javascript').
        document.getElementById('nav-contribute').className = 'active';

        var $list = $('#standard-nav');
        $('.page-detail h2, .page-detail h3, .page-detail h4')
            .each(function () {
                var $this = $(this);
                var text = $this.text();
                var anchor = text.toLowerCase().replace(/[^\w]+/g, '-');
                var tagName = $this.prop('tagName').toLowerCase();

                if (tagName === 'h2') {
                    $list.append('<a href="#' + anchor + '"><h4 class="inner">' + text + '</h4></a>');
                }
                else {
                    $list.append('<a href="#' + anchor + '">' + text + '</a>');
                }
            });

        $('.page-nav a').click(function () {
            $('.page-nav a').removeClass('active');
            $(this).addClass('active');
        });

        // Fix scroll position covered by nav
        window.addEventListener('hashchange', function() {
            scrollBy(0, -50);
        });

        $('.page-detail pre code').each(function (index, el) {
            $(el).addClass('prettyprint');
        });
        prettyPrint();

